class A
{
    public int i = 20;
    private static A aa = new A();//static 保证了只创建一次aa对象而不是反复调用

    private A()
    {

    }
    public static A getA()
    {
        return aa;
    }
}
public class TestStatic_1
{
    public static void main(String[] args)
    {
        A aa1 = A.getA();
        A aa2 = A.getA();
        aa1.i = 99;
        System.out.printf("%d\n",aa2.i);
    }
}
/*
上述程序展示了如何让一个类只能生成一个对象
*/